package cc.magicjson.mall.order.interfaces.rests;

import cc.magicjson.mall.order.application.command.CreateOrderCommand;
import cc.magicjson.mall.order.application.command.OrderQuery;
import cc.magicjson.mall.order.application.command.PlaceOrderCommand;
import cc.magicjson.mall.order.application.service.OrderApplicationService;
import cc.magicjson.mall.order.domain.model.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.UUID;

@RestController
@RequestMapping("/orders")
public class OrderController {

	private final OrderApplicationService orderApplicationService;

	public OrderController(OrderApplicationService orderApplicationService) {
		this.orderApplicationService = orderApplicationService;
	}

	@PostMapping("create")
	public ResponseEntity<String> createOrder(@RequestBody CreateOrderCommand command) {
		return ResponseEntity.ok(orderApplicationService.createOrder(command));
	}

	@GetMapping("/{orderId}")
	public ResponseEntity<OrderQuery> getOrder(@PathVariable("orderId") String orderId) {
		return ResponseEntity.ok(orderApplicationService.getOrder(orderId));
	}

}